package com.blockmeta.bbs.businesslibrary.launch;

import com.blockmeta.bbs.baselibrary.base.app.BaseApp;
import com.blockmeta.bbs.baselibrary.utils.SharedPreferenceUtil;
import com.blockmeta.bbs.baselibrary.utils.gson.GsonUtil;
import com.blockmeta.bbs.businesslibrary.pojo.IMConfigPOJO;
import java.util.HashMap;
import java.util.Map;

public class IMConfigYMAL implements IBaseYMAL {
    public static final String IM_CONFIG_YMAL = "IMConfigYMAL";
    public static IMConfigPOJO mIMConfig;
    @Override
    public Map<String, Object> parser(String content, String env) {
        try {
            mIMConfig = GsonUtil.buildGson().fromJson(content, IMConfigPOJO.class);
            SharedPreferenceUtil.putString(BaseApp.getApp(), "IMConfigYMAL", content);
        } catch (Exception e) {
        }
        return new HashMap<String, Object>();
    }

    public static IMConfigPOJO getIMConfig(){
        if(mIMConfig != null){
            return mIMConfig;
        }else {
            synchronized (IMConfigYMAL.class) {
                if(mIMConfig == null) {
                    String imConfigJsonStr = SharedPreferenceUtil.getString(BaseApp.getApp(), IM_CONFIG_YMAL, "");
                    mIMConfig = GsonUtil.buildGson().fromJson(imConfigJsonStr, IMConfigPOJO.class);
                }
            }
        }
        return mIMConfig;
    }
}
